/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.view.statementView;
/**
 * 说明：
 * 库存报表
 * @Author：
 * @Date：2012-03-21
 */
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;

import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import com.ruipengkj.component.jlist.ListButtonCellRenderer;
import com.ruipengkj.component.jlist.ListNodeButton;
import com.ruipengkj.component.jlist.StatementListPanel;
import com.ruipengkj.view.base.BasePanel;

public class StatementStockPanel extends BasePanel implements ListSelectionListener{
	
	private static final long serialVersionUID = 1L;
	
//	private StatementInventorySurplus statementInventorySurplus;//盘点盈余单汇总表
	private StatementInStockSummary statementInStockSummary;//盘点入库单汇总表
	private StatementOutStockSummary statementOutStockSummary;//盘点出库单汇总表
	private StatementInventoryWarning statementInventoryWarning;//库存预警汇总表
	private StatementStore statementStore;//仓库存量
	private StatementCommodityOutInSummary statementCommodityOutInSummary;//商品出入库汇总表
	
	private CardLayout right_layout;
	private JPanel right_panel;
	private DefaultListModel listModel;
	private JList btnList;//功能按钮列表
	public StatementStockPanel() {
		this.setLayout(new BorderLayout());
		this.init();
	}
	
	private void init() {
		listModel=new DefaultListModel();
		listModel.addElement(new ListNodeButton("盘点入库单汇总表"));
		listModel.addElement(new ListNodeButton("盘点出库单汇总表"));
		listModel.addElement(new ListNodeButton("库存预警汇总表"));
		listModel.addElement(new ListNodeButton("仓库存量统计表"));
		listModel.addElement(new ListNodeButton("商品出入库汇总表"));
		btnList=new StatementListPanel();
		btnList.setFixedCellHeight(35);
		btnList.setModel(listModel);
		btnList.setCellRenderer(new ListButtonCellRenderer());
		btnList.addListSelectionListener(this);
		btnList.setBackground(new Color(245, 250, 255));
		JSplitPane jsp = new JSplitPane();
		jsp.add(btnList, JSplitPane.LEFT, 0);
		jsp.add(initRight(), JSplitPane.RIGHT, 0);
		jsp.setDividerLocation(180);
		this.add(jsp, BorderLayout.CENTER);
		this.add(uiFactory.createFlowJPanel(), BorderLayout.SOUTH);
	}
	
	
	
	private JPanel initRight() {
		right_layout = new CardLayout();
		right_panel = new JPanel(right_layout);
		
		statementInStockSummary = new StatementInStockSummary();
		right_panel.add(statementInStockSummary, "b");
		right_layout.show(right_panel, "b");
		SwingUtilities.invokeLater(statementInStockSummary);
		return right_panel;
	}

	@Override
	public void clear() {
		
	}

	@Override
	public void valueChanged(ListSelectionEvent e) {
		switch (btnList.getSelectedIndex()) {
		case 0: {
			// 盘点入库单汇总表
			statementInStockSummary = new StatementInStockSummary();
			right_panel.add(statementInStockSummary, "b");
			right_layout.show(right_panel, "b");
			SwingUtilities.invokeLater(statementInStockSummary);
			break;
		}
		case 1: {
			// 盘点出库单汇总表
			statementOutStockSummary = new StatementOutStockSummary();
			right_panel.add(statementOutStockSummary, "c");
			right_layout.show(right_panel, "c");
			SwingUtilities.invokeLater(statementOutStockSummary);
			break;
		}
		case 2: {
			// 库存预警汇总表
			statementInventoryWarning = new StatementInventoryWarning();
			right_panel.add(statementInventoryWarning, "d");
			right_layout.show(right_panel, "d");
			SwingUtilities.invokeLater(statementInventoryWarning);
			break;
		}
		case 3: {
			//仓库存量统计表
			statementStore = new StatementStore();
			right_panel.add(statementStore, "e");
			right_layout.show(right_panel, "e");
			SwingUtilities.invokeLater(statementStore);
			break;
		}
		case 4: {
			//商品出入库汇总表
			statementCommodityOutInSummary = new StatementCommodityOutInSummary();
			right_panel.add(statementCommodityOutInSummary, "f");
			right_layout.show(right_panel, "f");
			SwingUtilities.invokeLater(statementCommodityOutInSummary);
			break;
		}
		}
		
	}
}
